#ifndef PARTICLE_H
#define PARTICLE_H
#include "mainwindow.h"

class ground;
class particle : public QObject
{
    Q_OBJECT
public:
    particle(QPointF Pos, float r, ground* groundHandle);
    void moveStep();
    void applygravity();
    void applyPressure(float ang, float magnitude);
    float DensitytoPressure(float density);
    void applynewton3_add(float fx, float fy, float mass, float dt);
    void applynewton3_sub(float fx, float fy, float mass, float dt);
    void xsph_add(float fx, float fy, float dt);
    void xsph_sub(float fx, float fy, float dt);
    QPointF GetPos(){
        return Pos;
    }
    QColor GetColor(){
        return color;
    }
    void SetColor(QColor color){
        this->color = color;
    }
    float GetPressure(){
        return pressureM;
    }
    float GetR(){
        return r;
    }
    void SetGvec(QPointF gvec){
        this->gvec = gvec;
    }
    float getvx(){
        return vx;
    }
    float getvy(){
        return vy;
    }
    void setvx(float vx){
        this->vx = vx;
    }
    void setvy(float vy){
        this->vy = vy;
    }
    QPointF getvxy(){
        return QPointF(vx,vy);
    }
    void setvxy(QPointF vxy){
        vx = vxy.x();
        vy = vxy.y();
    }
    void setdensity(float density){
        this->density = density;
    }
    float getdensity(){
        return density;
    }
    int GetIndex(){
        return index;
    }
    void SetIndex(int index){
        this->index = index;
    }
private:
    QPointF Pos;
    QPointF gvec;
    QColor color;
    ground* groundHandle;
    float pressureM;
    float vx;
    float vy;
    float r;
    float e = 0.3f;    // 反弹系数
    float drag = 1.f;// 空气阻尼
    float g = 0.15f;
    float density = 0;
    float targetdensity = 0.f;
    int index = -1;
};

#endif // PARTICLE_H
